<?php

/**
 * This is the model class for table "video".
 *
 * The followings are the available columns in table 'video':
 * @property string $id
 * @property string $title
 * @property string $video
 * @property string $embed_code
 * @property string $content
 * @property string $author
 * @property string $id_provider
 * @property string $image
 * @property string $categories
 * @property string $tags
 * @property string $type
 * @property string $id_video
 * @property string $published_date
 * @property string $created_date
 * @property string $modified_date
 * @property integer $status
 * @property integer $disabled
 * @property integer $count_view
 * @property integer $count_comment
 * @property integer $featured
 * @property integer $duration_time
 * @property string $slug
 */
class Video extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Video the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'video';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('title, author, id_provider, created_date', 'required'),
			array('status, disabled, count_view, count_comment, featured, duration_time', 'numerical', 'integerOnly'=>true),
			array('title, video, image, categories, tags, slug', 'length', 'max'=>255),
			array('author, id_provider', 'length', 'max'=>11),
			array('type, id_video', 'length', 'max'=>64),
            array('video', 'file', 'types'=>'flv, avi, mp4',
                'maxSize'=>1024 * 1024 * 1024 * 50, // 50MB
                'tooLarge'=>'The file was larger than 50MB. Please upload a smaller file.',
                ),
			array('embed_code, content, published_date, modified_date', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, title, video, embed_code, content, author, id_provider, image, categories, tags, type, id_video, published_date, created_date, modified_date, status, disabled, count_view, count_comment, featured, duration_time, slug', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'title' => 'Title',
			'video' => 'Video',
			'embed_code' => 'Embed Code',
			'content' => 'Content',
			'author' => 'Author',
			'id_provider' => 'Id Provider',
			'image' => 'Image',
			'categories' => 'Categories',
			'tags' => 'Tags',
			'type' => 'Type',
			'id_video' => 'Id Video',
			'published_date' => 'Published Date',
			'created_date' => 'Created Date',
			'modified_date' => 'Modified Date',
			'status' => 'Status',
			'disabled' => 'Disabled',
			'count_view' => 'Count View',
			'count_comment' => 'Count Comment',
			'featured' => 'Featured',
			'duration_time' => 'Duration Time',
			'slug' => 'Slug',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('title',$this->title,true);
		$criteria->compare('video',$this->video,true);
		$criteria->compare('embed_code',$this->embed_code,true);
		$criteria->compare('content',$this->content,true);
		$criteria->compare('author',$this->author,true);
		$criteria->compare('id_provider',$this->id_provider,true);
		$criteria->compare('image',$this->image,true);
		$criteria->compare('categories',$this->categories,true);
		$criteria->compare('tags',$this->tags,true);
		$criteria->compare('type',$this->type,true);
		$criteria->compare('id_video',$this->id_video,true);
		$criteria->compare('published_date',$this->published_date,true);
		$criteria->compare('created_date',$this->created_date,true);
		$criteria->compare('modified_date',$this->modified_date,true);
		$criteria->compare('status',$this->status);
		$criteria->compare('disabled',$this->disabled);
		$criteria->compare('count_view',$this->count_view);
		$criteria->compare('count_comment',$this->count_comment);
		$criteria->compare('featured',$this->featured);
		$criteria->compare('duration_time',$this->duration_time);
		$criteria->compare('slug',$this->slug,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}